package com.hymall.controller.wx;

import com.hymall.bean.MarketAddress;
import com.hymall.bean.common.BaseRespVo;
import com.hymall.bean.common.CommonData;
import com.hymall.service.wx.WxAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: 周子伟
 * @description ${}
 * @date: 2022/7/19 22:02
 */

@RestController
@RequestMapping("/wx/address")
public class WxAddressController {

    @Autowired
    WxAddressService wxAddressService;



    /*
    * @author Invoker
    * @description {地址增改功能}
    * @date 2022/7/20 9:42
    * @param [marketAddress]
    * @return com.hymall.bean.common.BaseRespVo
    */
    @PostMapping("save")

    public BaseRespVo save(@RequestBody MarketAddress marketAddress) {


        wxAddressService.save(marketAddress);

        return BaseRespVo.ok(marketAddress.getId());


    }

    /*
    * @author Invoker
    * @description {地址显示功能}
    * @date 2022/7/20 9:42
    * @param
    * @return
    */

    @GetMapping("list")
    public BaseRespVo list() {
        CommonData data = wxAddressService.List();

        return BaseRespVo.ok(data);
    }




    /*
    * @author Invoker
    * @description {地址删除功能}
    * @date 2022/7/20 9:43
    * @param
    * @return
    */

    @PostMapping("delete")

    public BaseRespVo delete(@RequestBody MarketAddress marketAddress) {

        wxAddressService.delete(marketAddress.getId());

        return BaseRespVo.ok(null);
    }


    @GetMapping("detail")

    public BaseRespVo detail(Integer id) {

        MarketAddress data = wxAddressService.detail(id);


        return BaseRespVo.ok(data);
    }


}
